package aiku.numericalcontroloa.Service.Impl;

import aiku.numericalcontroloa.Base.Utils.Result;
import aiku.numericalcontroloa.Service.DieBonusService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import aiku.numericalcontroloa.Model.Entity.DieBonus;
import aiku.numericalcontroloa.Mapper.DieBonusMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
* @author 马
* @description 针对表【die_bonus】的数据库操作Service实现
* @createDate 2024-05-13 16:59:37
*/
@Service
public class DieBonusServiceImpl extends ServiceImpl<DieBonusMapper, DieBonus>
    implements DieBonusService {
    /**
     * 查询分红比例
     * @return
     */
    @Autowired
    DieBonusMapper dieBonusMapper;


    @Override
    public Result getBonus() {
        DieBonus dieBonus = dieBonusMapper.selectById("1");
        if (dieBonus.getSeven() == null) {
            dieBonus.setSeven(BigDecimal.valueOf(0));
        }
        return Result.success("查询成功",dieBonus);
    }


    /**
     * 修改分红比率
     * @param dieBonus
     * @return
     */
    @Override
    public Result updateBonus(DieBonus dieBonus) {
        dieBonus.setDieBonusId("1");
        int i = dieBonusMapper.updateById(dieBonus);
        return i>0?Result.success("修改成功"):Result.error(201,"修改失败");
    }
}




